﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;
using Infragistics.Windows.DataPresenter;

namespace QLKS.Converters
{
    class DataGridIdConverter : IMultiValueConverter
    {
        #region IMultiValueConverter Members

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                if (values != null)
                    if (values[0] != DependencyProperty.UnsetValue)
                    {
                        Record rc = values[0] as Record;
                        if (rc != null)
                            if (rc.RecordType == RecordType.DataRecord)
                            {
                                if (rc != null)
                                    return (System.Convert.ToInt32(rc.Index) + 1).ToString();
                            }
                    }
                return "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return null;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
